<?php
class mysql{
	
	/*LOCALHOST*/
	protected $sHost;
	protected $sUser;
	protected $sPass;
	protected $sBase;
	protected $pConn;
	
	public function __construct()
	{
		if( $_SERVER['HTTP_HOST'] == 'localhost' )
		{
			$this->sHost = 'localhost';
			$this->sUser = 'root';
			$this->sPass = '';
			$this->sBase = 'db_capoterapia_revista';
		}
		else{
			$this->sHost = 'localhost';
			$this->sUser = 'root';
			$this->sPass = '';
			$this->sBase = 'db_revista';	
		}
	}
	
	public function conectar()
	{
		if( empty( $this->pConn ) )
		{
			$this->pConn = mysql_connect( $this->sHost, $this->sUser, $this->sPass ) or die ('Erro/conexao ' . mysql_error());
			mysql_select_db( $this->sBase ) or die('Erro ao selecionar o banco de dados');
		}
	}

	public function qry( $sql )
	{
		$this->conectar();
		
		mysql_query('SET NAMES "utf8"');
		mysql_query('SET character_set_connection=utf8');
		mysql_query('SET character_set_client=utf8');
		mysql_query('SET character_set_results=utf8');

		return mysql_query( $sql );
	}
	
}
?>
